using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class RandomEventUI : MonoBehaviour
{
    public static RandomEventUI instance;
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        
    }
    private void Start()
    {
        init(rEvents);
    }

    public Text eventText;
    public Transform optionsBar;
    public GameObject options;
    public Transform guaBar;
    public GameObject gua;
    public RandomEvents rEvents;
    int conversation;

    public void init(RandomEvents random)
    {
        rEvents = random;
        conversation = 0;
       
        eventText.text = rEvents.randomEvents[conversation].EventText;
        Transform[] items = optionsBar.GetComponentsInChildren<Transform>();
        for (int i = 1; i < items.Length; i++)
        {
            Destroy(items[i].gameObject);
        }
        //for (int i = 0; i < rEvents.randomEvents[conversation].options.Count; i++)
        //{
        //    OptionClass oprtionData = rEvents.randomEvents[conversation].options[i];
        //    Oprtion oprtion = Instantiate(options, optionsBar).GetComponent<Oprtion>();
        //    oprtion.str = tishi(oprtionData);
        //    if (oprtion.str != "")
        //    {
        //        for (int j = 0; j < oprtionData.optionEvents.Count; j++)
        //        {
                   

        //        }
        //    }
        //    oprtion.option = oprtionData;
        //    oprtion.text.text = oprtionData.optionText;
        //}
    }
    //public void next()
    //{
    //    conversation +=1;
       
    //    eventText.text = rEvents.randomEvents[conversation].EventText;
    //    Transform[] items = optionsBar.GetComponentsInChildren<Transform>();
    //    for (int i = 1; i < items.Length; i++)
    //    {
    //        Destroy(items[i].gameObject);
    //    }
    //    for (int i = 0; i < rEvents.randomEvents[conversation].options.Count; i++)
    //    {
    //        OptionClass oprtionData = rEvents.randomEvents[conversation].options[i];
    //        Oprtion oprtion = Instantiate(options, optionsBar).GetComponent<Oprtion>();
    //        oprtion.str = tishi(oprtionData);
    //        if (oprtion.str != "")
    //        {
    //            for (int j = 0; j < oprtionData.optionEvents.Count; j++)
    //            {
                    

    //            }
    //        }
    //        oprtion.option = oprtionData;
    //        oprtion.text.text = oprtionData.optionText;
    //    }
    //}
    //public void jump(int index)
    //{
    //    conversation = index;
       
    //    eventText.text = rEvents.randomEvents[conversation].EventText;
    //    Transform[] items = optionsBar.GetComponentsInChildren<Transform>();
    //    for (int i = 1; i < items.Length; i++)
    //    {
    //        Destroy(items[i].gameObject);
    //    }
    //    for (int i = 0; i < rEvents.randomEvents[conversation].options.Count; i++)
    //    {
    //        OptionClass oprtionData = rEvents.randomEvents[conversation].options[i];
    //        Oprtion oprtion = Instantiate(options, optionsBar).GetComponent<Oprtion>();
    //        oprtion.str = tishi(oprtionData);
    //        if (oprtion.str != "")
    //        {
    //            for (int j = 0; j < oprtionData.optionEvents.Count; j++)
    //            {
                   

    //            }
    //        }
    //        oprtion.option = oprtionData;
    //        oprtion.text.text = oprtionData.optionText;
    //    }



    //}

    public string tishi(OptionClass oprtionData)
    {

        string sth ="";
        for (int i = 0; i < oprtionData.optionEvents.Count; i++)
        {
            switch (oprtionData.optionEvents[i].eventE)
            {
               



            }
        }

        return sth;
    }
}
